package com.hooper.dp.consumer;

import com.hooper.dp.dto.OrderMessage;
import com.hooper.dp.service.IVoucherOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author Tim Hooper
 * @version 1.0
 * @time 2023/04/25/21:12
 */
@Component
@Slf4j
public class OrderMessageHandler {

    @Resource
    private IVoucherOrderService voucherOrderService;


    @RabbitListener(queues = "order.queue")
    public void handleOrderMessage(OrderMessage msg) {
        log.info("收到订单消息：{}", msg);
        voucherOrderService.createOrder(msg);
        log.info("订单创建成功");
    }

}
